package com.grumoon.volleydemo.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.grumoon.volleydemo.R;
import com.grumoon.volleydemo.util.LruImageCache;
import com.grumoon.volleydemo.util.StringUtil;
import com.grumoon.volleydemo.util.VolleyUtil;

/**
 * 
 ***************************************************** 
 * <hr>
 * <dt><span class="strong">类功能简介:</span></dt>
 * <dd>Coffee</dd>
 * <dt><span class="strong">创建时间:</span></dt>
 * <dd>2015-3-19 下午3:06:17</dd>
 * <dt><span class="strong">公司:</span></dt>
 * <dd>NetworkImageViewAdapter</dd>
 * 
 * @author aa1000777 - Email:aa1000777@qq.com
 ***************************************************** 
 */
public class NetworkImageViewAdapter extends ImageBaseAdapter {

	private ImageLoader imageLoader;

	public NetworkImageViewAdapter(Context context, String[] imageUrlArray) {
		super(context, imageUrlArray);
		this.imageLoader = new ImageLoader(VolleyUtil.getQueue(context), new LruImageCache());
	}

	@Override
	int getItemLayout() {
		return R.layout.fr_network_image_view_list_item;
	}

	@Override
	void setImage(ImageView imageView, String imageUrl) {
		NetworkImageView networkImageView = (NetworkImageView) imageView;
		networkImageView.setDefaultImageResId(R.drawable.ic_empty);
		networkImageView.setErrorImageResId(R.drawable.ic_empty);
		networkImageView.setImageUrl(StringUtil.preUrl(imageUrl), imageLoader);
	}

}
